import { generateColors } from '@/utils/theme'
import { getItem } from '@/utils/loaclstorage'
import { MAIN_COLOR } from '@/constant'
/**
 * 快速访问变量
 */

const getters = {
  token: state => state.user.token,
  // 判断用户信息是否存在
  hasUserInfo: state => {
    return JSON.stringify(state.user.userInfo) !== '{}'
  },
  userInfo: state => state.user.userInfo,
  // 预设css常量
  cssVar: state => ({
    ...state.theme.variables,
    ...generateColors(getItem(MAIN_COLOR))
  }),
  // 菜单侧边栏伸缩状态
  sidebarOpened: state => state.app.sidebarOpened,
  // 国际化语言状态
  language: state => state.app.language,
  // 快速访问主题颜色
  mainColor: state => state.theme.mainColor,
  // 快速访问 tags
  tagsViewList: state => state.app.tagsViewList
}

export default getters
